package com.hqyj.demo.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import sun.awt.image.BufImgSurfaceData;

/**
 * 项目:shop-admin-240701
 * 描述:
 * 时间:2024/9/29 15:57
 * 作者:admin
 * 版本:1.0
 **/
@PropertySource(value = "classpath:config/myConfig.properties",encoding = "utf-8")
@Component
public class BrowerConfig  implements CommandLineRunner {

    //是否打开浏览器
    @Value("${openUrl}")
    private boolean isUrl;

    //浏览器地址
    @Value("${brower}")
    private String brower;

    //端口号
    @Value("${server.port}")
    private Integer port;


    @Override
    public void run(String... args) throws Exception {
        //拼接执行cmd的命令
        String command = brower +" http://localhost:"+port+"/test";

        Runtime run = Runtime.getRuntime();
        if(isUrl){
            run.exec("D:\\Program Files (x86)\\python36\\python.exe E:\\game\\demo.py");
        }


    }
}
